Human Computer Communication

Author

Ken Pu

1 Communicating With Different Computing Frameworks

  • A runtime environment for computing
  • Communicating with the runtime environment

2 Communtating with Foundational Models of Computation

2.1 Turing Machine

https://web.mit.edu/manoli/turing/www/turing.html
  • A tape with cells containing symbols.
  • A read/write head to access and update the tape.
  • A control logic controlling the head movement and read/write operations.

2.2 Programming with TM

q0, in_symbol, q1, out_symbol, movement
q0, in_symbol, q1, out_symbol, movement
q0, in_symbol, q1, out_symbol, movement
q0, in_symbol, q1, out_symbol, movement

where

  • q0 is the source state
  • in_symbol is when in_symbol is read from the current cell
  • q1 is the state to transition to
  • out_symbol is the symbol to write to the current cell
  • movement\(\in\{\mathrm{left}, \mathrm{right}, \mathrm{nomove}\}\)

A sample TM

2.3 Lambda Calculus

Simple syntax

  • Variable names: \(x\), \(y\), \(\dots\)
  • Function declaration: \(\lambda x. \mathrm{expression}\)
  • Function invocation: \((\mathrm{expression}\ \mathrm{argument})\)

Rewriting rules

  • Parameter renaming (\(\alpha\)-conversion): \(\lambda x. e \longrightarrow \lambda x'.e[x'/x]\)
  • Function evaluation (\(\beta\)-reduction): \(((\lambda x.e) y)\longrightarrow e[y/x]\)
  • Optimization (\(\eta\)-reduction): \(\lambda x.(f\ x)\longrightarrow f\)

2.4 Programming with LC

  • \(pred = λn.λf.λx.n (λg.λh.h (g f)) (λu.x) (λu.u)\)
  • \(3 = λf.λx.f (f (f x))\)
  • \((pred\ 3)\)

https://lambdacalc.io/

3 General Purpose Programming Languages

3.1 The C programming language

Runtime environment

  • Variables
  • Functions
  • Arrays
  • Structures
  • Direct memory access

Programming in C

void f() {
    int[] numbers = {1, 2, 3, 4};
    int *ptr;
    ptr = numbers + 2;
    printf("%d\n", (*ptr));
}

3.2 The Python programming language

Runtime environment

  • Functions with closure
  • Lists, dictionaries
  • Packages

Programming in Python

import os
from pprint import pprint
def show_env(keys):
    env = {k:os.environ[k] for k in keys}
    pprint(env)

3.3 Clojure

Runtime environment

  • namespaces
  • functional programming
  • data transformation

Programming in Python

(require '[clojure.pprint :refer [pprint])
(require '[environ.core :refer [env])

(defn show-env [keys]
  (->> keys
       (map env)
       (zip keys)
       (hash-map)
       (pprint)))

4 High Level Languages

4.1 SQL

Runtime environment

  • Relational tables
  • First order logic
  • Relational algebra with aggregation

Programming in SQL

WITH T_MIN(name, course_min, grade_min AS (
  SELECT name, course, grade
  FROM courses
  WHERE (name, grade) IN (
    SELECT name, MIN(grade) FROM courses
    GROUP BY name
  )
),
T_MAX(name, course_max, grade_max AS (
  SELECT name, course, grade
  FROM courses
  WHERE (name, grade) IN (
    SELECT name, MAX(grade) FROM courses
    GROUP BY name
  )
)
SELECT T_MIN NATURAL JOIN T_MAX;

4.2 ChatGPT

Runtime environment

  • ???

Prompting in natural language

There is a table `T(name TEXT, course TEXT, grade DOUBLE)` 
that stores the grades of the students.

Write a SQL statement that
lists all the students with their lowest grade
and their highest grade, and the respective courses.

5 Graphical Interfaces

5.1 Apps and interfaces

Desktop Application

Mobile App

Angry Bird

6 Design Space